<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('产品图库')"/>
</head>
<body class="gray-bg">
    <div class="container-div">
        <div class="row">
            <div class="container-div">
                <div class="btn-group-sm" id="toolbar" role="group">
                    <h5>图片库</h5>
                    <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:config:add">
                        <i class="fa fa-plus"></i> 图片上传
                    </a>
                </div>
                <div class="col-sm-12 select-table table-striped">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer"/>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:post:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:post:remove')}]];
        var datas = [[${@dict.getType('sys_normal_disable')}]];
        var prefix = ctx + "product/pic";

        $(function () {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove/{id}",
                sortName: "picId",
                modalName: "图片",
                columns: [
                    {
                        checkbox: true
                    },
                    {
                        field: 'picId',
                        title: '编号',
                        sortable: true
                    },
                    {
                        field: 'picName',
                        title: '名称',
                    },
                    {
                        title: '图片',
                        formatter: function(value, row, index) {
                            return $.table.imageView(row.picUrl);
                        }
                    },
                    {
                        field: 'picDesc',
                        title: '图片描述',
                    },
                    {
                        title: '操作',
                        align: 'center',
                        formatter: function (value, row, index) {
                            var actions = [];
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.picId + '\')"><i class="fa fa-edit"></i>选定为产品配图</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.picId + '\')"><i class="fa fa-trash"></i>删除</a>');
                            return actions.join('');
                        }
                    }
                ]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>